import { ReqCategoryList, ReqSlideList, ReqFloorList } from "@/api/index";
const state = {
  CategoryList: [],
  slide: [],
  floor: [],
};
const mutations = {
  // 唯一修改数据的地方
  //三级分类
  SAVE_CATEGPRY_lIST(state, value) {
    state.CategoryList = value;
  },
  //轮播图
  SAVE_SLIDE_lIST(state, value) {
    state.slide = value;
  },
  //   楼层
  SAVE_FLOOR_lIST(state, value) {
    state.floor = value;
  },
};
const actions = {
  // 三级分类方法
  async asyncCategoryList({ commit }) {
    let data = await ReqCategoryList();
    // console.log(data);
    commit("SAVE_CATEGPRY_lIST", data.splice(0, 15));
  },

  //  轮播图方法
  async asyncSlideList({ commit }) {
    let data = await ReqSlideList();
    commit("SAVE_SLIDE_lIST", data);
  },
  //   楼层方法
  async asyncFloorList({ commit }) {
    let data = await ReqFloorList();
    commit("SAVE_FLOOR_lIST", data);
  },
};
const getters = {};

//这里不能有vuex
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
